package com.zang.blogz.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.zang.blogz.annotation.OptLog;
import com.zang.blogz.constant.OptTypeConstant;
import com.zang.blogz.entity.WebsiteConfig;
import com.zang.blogz.result.Result;
import com.zang.blogz.service.WebsiteConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 朵橙i
 * @since 2022-06-21
 */
@RestController
@RequestMapping("/blogz/websiteConfig")
@Api(tags = "用户信息")
@SaCheckRole("管理员")
public class WebsiteConfigController {
    @Autowired
    private WebsiteConfigService websiteConfigService;

    @PostMapping("/admin/update")
    @ApiOperation(value = "修改配置信息", notes = "修改配置信息")
    @OptLog(optType = OptTypeConstant.UPDATE)
    public Result<String> saveWebsiteConfig(@RequestBody WebsiteConfig websiteConfig) {

        if (websiteConfigService.saveOrUpdate(websiteConfig)) {

            return Result.error("修改成功");
        }

        return Result.error("修改失败");
    }
}
